/**
 * 重置样式的HOc
 */
import classnames from "classnames";
import { createElement } from "react";
import "../../styles/index.less";

/**
 * 覆盖样式用的HOC
 * @param {(p?: any) => JSX.Element} node
 * @param {{wrappers: string[]}} props
 * @return () => React.node
 */
const ResetStyle = (node, props = {}) => {
	const { wrappers = [], style } = props;
	return (compProps = {}, ref) => {
		return (
			<div className={classnames(...wrappers)} style={style}>
				{createElement(node, { ...compProps, forwardedRef: ref })}
			</div>
		);
	};
};

export default ResetStyle;
